package com.fhc.view.utils

import androidx.compose.runtime.Composable
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.stringResource
import com.fhc.view.R
import es.dmoral.toasty.Toasty

@Composable
fun ToastyShow(msg: String, iconRes:Int? = null, bgColorRes:Int? = null, duration:Int = 3000, showAfter: ()-> Unit){
    Toasty.custom(
        LocalContext.current,
        msg,
        iconRes ?: R.drawable.ic_info_outline_white,
        bgColorRes ?: R.color.toastInfoColor,
        duration,
        iconRes != null,
        bgColorRes != null
    ).show()
    showAfter()
}
@Composable
fun ToastyShow(msgRes:Int,  msgArgs: Array<Any>? = emptyArray<Any>(), iconRes:Int? = null, bgColorRes:Int? = null, duration:Int = 3000, showAfter: ()-> Unit){
    if(msgArgs!= null && msgArgs.isNotEmpty()) ToastyShow(msg = stringResource(id = msgRes, *msgArgs), iconRes = iconRes, bgColorRes = bgColorRes, duration = duration , showAfter = showAfter)
    else ToastyShow(msg = stringResource(id = msgRes), iconRes = iconRes, bgColorRes = bgColorRes, duration = duration , showAfter = showAfter)
}
